<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="UTF-8">
		<title></title>
		 <base th:href="${#request.getContextPath()}+'/'">
		<script type="text/javascript" src="js/jquery.min.js"></script>
					<link rel="stylesheet" type="text/css" href="css/layui.css"/>
				<script src="layui.js" type="text/javascript" charset="UTF-8"></script>
			 <script src="js/index.js" charset="UTF-8"></script>
			 <script type="text/javascript">

			 //获取表单数据中的值
			    layui.use('form', function(){
				   var $ = layui.jquery;
				   var form = layui.form;
				   var layer=layui.layer;
				   form.on('submit(formDemo)', function(data){
					   });
				   //监听提交
				   return false;
				 }); 
			    var array = new Array(); 
			  function findRoom(){
				  array.splice(0,array.length);
				  var options=$("#mytest option:selected");
				   var rtid=options.val();
				   var finddate=$("#finddate").val();
		//获取选中的值
		if(array.length==0){
			$("input[name='test01']:checked").each(function() {
				var xz=$(this).val();
				array.push(xz)
			});
		}
		//遍历array
		for(var i=0;i<array.length;i++){
			if(array[i]==1){
				var rwindow="有";
			}
			if(array[i]==2){
				var rfoot="有";
			}
			if(array[i]==3){
				var rsping="有";
			}
		}

				  $.ajax({
					   url:"/myfind02",
					   dataType:"json",
					   data:{rwindow:rwindow,
						   rfoot:rfoot,
						   rsping:rsping,
						   rtid:rtid,
						   finddate:finddate
						   },
					   type:"post",
					   success:function(data){
			 				var html;
			 				//var mydate=$("#finddate").val();
						  	$("#show").html("");
							for(var i=0;i<data.length;i++){
								html="<div id='' style='height: 180px; margin-bottom: 10px;' class='layui-bg-gray'>"+
								"<div id='' style='width: 400px; height: 180px; float: left; '>"+
								"<img src=img/"+data[i].imgp+" style='width: 400px; height: 180px; '/><br />"+
								"</div>"+
								"<div style='width: 910px;height: 180px;float: right; margin-left: 30px;' >"+
								"<span style='color: #870a20;float: left'>名称:"+data[i].rtname+"</span><br/>"+
								"<span style='color: #666666;float: left;margin-bottom:20px;'>"+data[i].rmessage+"</span><br /><br />"+
								"<div id=''>"+
								"<span style='color: #870a20;'>享有服务：</span>窗户 <span style='color: #870a20;'>"+data[i].rwindow+"</span><br />"+
								"<span style='margin-left: 70px;'>早餐</span> <span style='color: #870a20;'>"+data[i].rfood+"</span><br />"+
								"<span style='margin-left: 70px;'>汤水</span>  <span style='color: #870a20;'>"+data[i].rspring+"</span><br /></div>"+
								"<span style='float: left;line-height: 38px;color: #ff4400;'>价格:￥"+data[i].rprice+"元/天</span>"+
								"<button "+
								"class='layui-btn layui-btn-sm' style='float: right;'  >查看评价</button>"+
								"<div class='site-demo-button' id='layerDemo' style='display: inline-block; float: left;'>"+
							    "<button  style='margin-left: 40px' data-method='offset' data-value="+data[i].rtid+" data-type='auto' class='layui-btn layui-btn-sm'"+
							    ">查看详情</button></div>"+
								"<button class='layui-btn layui-btn-warm layui-btn layui-btn-sm' style='float: right;' onclick='addCart("+data[i].rtid+",\""+data[i].imgp+"\",\""+data[i].rtname+"\","+data[i].rprice+")'>加入购物车</button>"+
								"</div></div>"
							$(html).appendTo($("#show"));
							
							}
					   }
				   })  
			  }
			  
				
			 var mydate;
			 $(function(){
					      $.ajax({
					         type:"get",
					         url:"header.html",
					         async:true,
					         success:function(data){
					            $("#header").html(data);
					            
					         }
					      });
				 var mydate=$("#hd").val();
				 $('#finddate').val(mydate);
				if(mydate==null){
						return;
				 } 
					$.ajax({
			 			url:"/myfind01",
			 			dataType:"json",
			 			data:{date:mydate},
			 			type:"post",
			 			success:function(data){
			 				var mydate=$("#finddate").val();
			 				var html;
							for(var i=0;i<data.length;i++){
							html="<div id='' style='height: 180px; margin-bottom: 10px;' class='layui-bg-gray'>"+
							"<div id='' style='width: 400px; height: 180px; float: left; '>"+
							"<img src=img/"+data[i].imgp+" style='width: 400px; height: 180px; '/><br />"+
							"</div>"+
							"<div style='width: 910px;height: 180px;float: right; margin-left: 30px;' >"+
							"<span style='color: #870a20;float: left'>名称:"+data[i].rtname+"</span><br/>"+
							"<span style='color: #666666;float: left;margin-bottom:20px;'>"+data[i].rmessage+"</span><br /><br />"+
							"<div id=''>"+
							"<span style='color: #870a20;'>享有服务：</span>窗户 <span style='color: #870a20;'>"+data[i].rwindow+"</span><br />"+
							"<span style='margin-left: 70px;'>早餐</span> <span style='color: #870a20;'>"+data[i].rfood+"</span><br />"+
							"<span style='margin-left: 70px;'>汤水</span>  <span style='color: #870a20;'>"+data[i].rspring+"</span><br /></div>"+
							"<span style='float: left;line-height: 38px;color: #ff4400;'>价格:￥"+data[i].rprice+"元/天</span>"+
							"<button "+
							"class='layui-btn layui-btn-sm' style='float: right;'  >查看评价</button>"+
							"<div class='site-demo-button' id='layerDemo' style='display: inline-block; float: left;'>"+
						    "<button  style='margin-left: 40px' data-method='offset' data-value="+data[i].rtid+" data-type='auto' class='layui-btn layui-btn-sm'"+
						    ">查看详情</button></div>"+
							"<button class='layui-btn layui-btn-warm layui-btn layui-btn-sm' style='float: right;' onclick='addCart("+data[i].rtid+",\""+data[i].imgp+"\",\""+data[i].rtname+"\","+data[i].rprice+")'>加入购物车</button>"+
							"</div></div>"
							$(html).appendTo($("#show"));	
							
							}
			 			}
			 			
			 			})
			 })
			function lj(rtid){
				 var mydate=$("#finddate").val();
				 location.href="order/or?rtid="+rtid+"&date="+mydate
			 }
			  function findmy(rtid){
				  alert("rtid"+rtid)
			  }
			 
			 function addCart(rtid,imgp,rtname,rprice){
				 var mydate=$("#finddate").val();
					$.ajax({
						url:"/cart/cart",
						type:"post",
						data:{
							id:rtid,
							img:imgp,
							type:rtname,
							rtid:rtid,
							price:rprice,
							number:1,
							date:mydate
						},
						success:function(data){
							alert(data);
						}
					});
				}
			 </script>
	</head>
	<body class="layui-bg-gray" background="">
	<header class="header" id="header"></header><br/><br/>
	<div style="width:100%;text-align:center">
	<div class="layui-form">
		 <div class="layui-inline">
      <label class="layui-form-label">日期范围</label>
      <div class="layui-input-inline">
        <input type="text" class="layui-input" id="finddate" name="finddate" placeholder=" - ">
      </div>
    </div>
  <div class="layui-input-inline">
    <label class="layui-form-label">房间类型</label>
    <div class="layui-input-block" style="width: 250px;">
      <select name="city" lay-verify="required" id="mytest">
      	<option value="0"></option>
        <option value="1">豪华大床房</option>
        <option value="2">豪华双人间</option>
        <option value="4">豪华家庭套房</option>
        <option value="5">经济双人间1</option>
        <option value="6">经济双人间2</option>
        <option value="7">经济大床房</option>
      </select>
    </div>
    
  </div>
  
  <div class="layui-input-inline" style="text-align: center; line-height: ;">
  	<label class="layui-form-label">享有服务</label>
    <div class="layui-input-block">
      <input type="checkbox" name="test01" id="my01" title="窗户" value="1">
      <input type="checkbox" name="test01" id="my02" title="早餐" value="2">
      <input type="checkbox" name="test01" id="my03" title="汤水" value="3" >
    </div>
  </div>
  <div class="layui-input-inline">
      <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="formDemo" onclick="findRoom()">查询</button>
    </div>
	</div>
</div>
<input th:value="${date}" type="hidden"  id="hd"  />
</div>
	<div class="layui-card">
  <div class="layui-card-header" style="background: #d2d2d2; height: 30px; text-align: center;line-height: 30px; font-size: 13px;">
  客房类型
  	<span style="float: right; padding-left: 0;margin-right: 200px;">平均每晚</span>
  	<span style="float: right; padding-left: 0;margin-right: 300px;">房间介绍</span>
  </div>
 <div id="show">

 </div> 

</div>
	</body>
</html>
